#ifndef CMD_PROFILE_H
#define CMD_PROFILE_H

#include <stdarg.h>
#include <sys/queue.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef void (*cmd_profile_func_t)(void *desc);

int cmd_load_profile(void *desc, const char *fmt, ...);


struct bprofile{
  const char *name;
  const char *after;
  cmd_profile_func_t func;
  TAILQ_ENTRY(bprofile) entry;
};

void register_profile(struct bprofile *prof);


#define BOLT_PROFILE(n,a,f,desc)              \
  static void bolt_prof_func_##f(void *desc); \
  static struct bprofile _d_prof_##n = {  \
    .name = #n,                               \
    .after = a,                               \
    .func = bolt_prof_func_##f                \
  };                                          \
  static void __attribute__((constructor)) _prof_s_func_##f(void) \
  {                                                               \
    register_profile(&_d_prof_##n);                               \
  }                                                               \
  static void bolt_prof_func_##f(void *desc) 

#ifdef __cplusplus
}
#endif

#endif


